#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
    int a = 0;
    scanf("%d", &a);
    for (int i = 1; i <= 2019; i++) {
        if (i % 10 == 9 || i / 10 % 10 == 9 || i / 100 % 10 == 9)
            a++;
    }
    printf("%d\n", a);
}